class Solution:
    def deleteDuplicates(self, head: ListNode) -> ListNode:
        if head is None:
            return head

        only = head

        while only and only.next:
            if only.val == only.next.val:
                only.next = only.next.next
            else:
                only = only.next
        return head